import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 * Date: 2024-04-18
 * Time: 23:19
 */

/**
 * 字节流:InputStream
 * 一次读byte[]个字符
 */
public class Demo4_2 {
    public static void main(String[] args) {
        try(InputStream inputStream = new FileInputStream
                ("E:\\img\\春天\\微信图片_20240416171355.jpg")){

            while(true){
                byte[] bytes =new byte[1024];
                int n =  inputStream.read(bytes);
                System.out.println("n = "+n);
                if(n==-1){
                    break;
                }
                for (int i = 0; i < n; i++) {
                    System.out.printf("0x%x " ,bytes[i]);
                }
                System.out.println();
            }

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
